package com.boot2523.service;


import com.boot2523.bean.Order;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

@Service
public class OrderConsumer {
    /**
     * @RabbitListener监听指定队列中的消息
     * @param order
     */
    @RabbitListener(queues = "${order.queue}")
    public void receiveOrder(Order order) {
        System.out.println("Received order: " + order);
        // 模拟订单处理逻辑
        processOrder(order);
    }

    private void processOrder(Order order) {
        System.out.println("Processing order with ID: " + order.getOrderId());
        // 这里可以添加实际的业务逻辑，如保存到数据库、调用其他服务等
    }
}
